package edu.put.sk.nrpp.ui;


import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;

import edu.put.sk.nrpp.ConnectionList;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.BorderLayout;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;

public class RouterWindow {
	private JFrame frmSetupProgram;

	/**
	 * Create the application.
	 */
	public RouterWindow(GraphicsRouter gr) {
		initialize(gr);
	}
	private void initialize(GraphicsRouter gr) {
		setFrame(new JFrame());
		getFrame().setBounds(100, 100, 472, 363);
		//getFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		getFrame().setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frmSetupProgram.getContentPane().setLayout(null);
		
		JLabel lblNazwaroutera = new JLabel("Nazwa routera:");
		lblNazwaroutera.setBounds(10, 11, 180, 14);
		frmSetupProgram.getContentPane().add(lblNazwaroutera);
		System.out.println(gr.router.hostname);
		JLabel nazwaRoutera = new JLabel(gr.router.hostname);
		nazwaRoutera.setBounds(10, 30, 46, 14);
		frmSetupProgram.getContentPane().add(nazwaRoutera);
		
		JLabel lblSsiedzi = new JLabel("Sąsiedzi:");
		lblSsiedzi.setBounds(10, 53, 180, 14);
		frmSetupProgram.getContentPane().add(lblSsiedzi);
		
		for (int i=0;i<gr.router.numberOfNeighbors;i++){
			JLabel nazwaSasiada = new JLabel(gr.router.connections.get(i).getNeighbor(gr.router).hostname);
			nazwaSasiada.setBounds(10, 78+20*i, 164, 14);
			frmSetupProgram.getContentPane().add(nazwaSasiada);
			
			JLabel adresIP = new JLabel("255.255.255.255");
			adresIP.setBounds(242, 78+20*i, 164, 14);
			frmSetupProgram.getContentPane().add(adresIP);
		}
	}

	/**
	 * @param frame the frame to set
	 */
	public void setFrame(JFrame frame) {
		this.frmSetupProgram = frame;
		frmSetupProgram.setTitle("Setup");
	}

	/**
	 * @return the frame
	 */
	public JFrame getFrame() {
		return frmSetupProgram;
	}
}
